home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / UT_SYSTM / OS9MAX.ZIP / EXITCODE.BAT < prev    next >
Encoding:
DOS Batch File  |  1994-11-17  |  2.6 KB  |  80 lines

  1. @echo off
  2.  
  3. REM **************************************************************************
  4. REM Progams always terminates with an exitcode.  The value of this will depend
  5. REM on the termination purpose. At this point the following codes are defined:
  6. REM
  7. REM 0  EXIT_NORMAL                (e.g. $ exit 0  = program terminated)
  8. REM 1  EXIT_ON_ERRORS             (e.g. $ exit 1  = program aborted)
  9. REM
  10. REM The exitcode can be specified as a parameter to the 'exit' command:
  11. REM
  12. REM $ exit 12                     ;* terminate program  and return exitcode 12
  13. REM
  14. REM The user or programmer may simply utilize  this exitcode for writing batch
  15. REM files  which allows special handling (gosub/gotos/chain/fork)  or re-start
  16. REM of the program after termination.
  17. REM
  18. REM If you start the program from within a procedure file (batch) the exitcode
  19. REM can be analyzed with the 'if errorlevel==' command. We highly recommend to
  20. REM refer to the MS-DOS manual for further information on writing  batch files
  21. REM and to get familiar with this special command and errorlevel handling.
  22. REM
  23. REM OS9MAX allows to write a procedure (batch) file from within the program by
  24. REM means of the 'mkbatch' command. Please refer to the online help. This
  25. REM command allows to execute commands (DOS SHELL) from OS9MAX:
  26. REM
  27. REM 1. Write a procedure file (mkbatch)
  28. REM 2. Exit with errorlevel (will jump to the correct item in this file)
  29. REM 3. Execute procedure file
  30. REM 4. Return (restart OS9MAX)
  31. REM
  32. REM Important Notice
  33. REM ----------------
  34. REM This is an example, please customize the commandline (drv/fmt). If you
  35. REM have any questions regarding this part of the documentation please send
  36. REM us a fax. As always : your suggestions are highly welcome. If you have
  37. REM any needs which are not covered by this state of implementation call us!
  38. REM
  39. REM **************************************************************************
  40.  
  41. :START
  42.  
  43. REM OS9MAX B: 38U0 /m0 'cat'
  44. REM OS9MAX B: 38U0 /m0 SCRIPT.CMD
  45.     OS9MAX B: 38U0 /m0
  46.  
  47.    if errorlevel==4 goto INV
  48.    if errorlevel==3 goto E03
  49.    if errorlevel==2 goto E02
  50.    if errorlevel==1 goto E01
  51.    if errorlevel==0 goto E00
  52.  
  53. :E00
  54.    echo *** Normal Termination
  55.    goto EXIT
  56.  
  57. :E01
  58.    echo *** Error Termination
  59.    goto EXIT
  60.  
  61. :E02
  62.    echo *** Start Subprocess and Return
  63.    REM The following file may be created from within OS9MAX
  64.    REM i.e.: '$ mkbatch child.bat cmd1 cmd2...'
  65.  
  66.    call child.bat        
  67.    goto START
  68.  
  69. :E03
  70.    echo *** Execute Command and Return
  71.    dir
  72.    goto START
  73.  
  74. :INV
  75.    echo *** Unknown Errorlevel
  76.    goto EXIT
  77.  
  78. :EXIT
  79.  
  80.